const graph = require('./graph')

const visited = new Set()
const dfs = (root) => {
    // 访问根节点
    console.log(root)
    // 已经访问过的添加记录
    visited.add(root)
    graph[root].forEach(item => {
        if (!visited.has(item)) {
            dfs(item)
        }
    })
}

const res = dfs(2)
console.log(res)